home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
cuj9205.zip
/
1005048A
< prev
next >
Wrap
Text File
|
1992-06-02
|
854b
|
31 lines
Listing 1. Impulse response function
#include <stdio.h>
void impulse_response(FILE *out, int N,
double a, double b, double c)
{
double
y = c, /* The most recent system output value */
y1 = 0; /* The previous output */
/* Time t = 0, before the impulse. */
fprintf(out, "%lg\n", y1);
/* Time t = 1, the instant of the impulse. */
fprintf(out, "%lg\n", y);
N -= 2; /* Two points already written */
/* All later times, t > 1 */
while(N-- >= 0)
{
double t = y;
y = a*y + b*y1;
y1 = t;
fprintf(out, "%lg\n", y);
}
}